package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.stereotype.Controller;

import com.zr.service.ShowEIRService;

import net.sf.json.JSONObject;
/**
 * lxg
 * @author Administrator
 *
 */
@Controller
public class ShowEIRAction implements ServletResponseAware{
	private HttpServletResponse resp;
	private int page;
	private int rows;
	
	
	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	@Override
	public void setServletResponse(HttpServletResponse arg0) {
		// TODO Auto-generated method stub
		this.resp=arg0;
	}
	@Resource
	private ShowEIRService shEIRseim;
	
	public void showEIR(){
		resp.setCharacterEncoding("utf8");
		try {
			PrintWriter pw=resp.getWriter();
			
			JSONObject jo=shEIRseim.getReceipt(page, rows);
			pw.write(jo.toString());
			pw.flush();
			pw.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
